package com.ym.spring;

import cn.hutool.extra.spring.SpringUtil;
import com.ym.common.constant.DictEnum;
import com.ym.core.shiro.ShiroUtil;
import com.ym.medical.domain.entity.DoctorStudioEntity;
import com.ym.medical.domain.entity.UserDoctorViewEntity;
import com.ym.medical.domain.entity.UserEntity;
import com.ym.medical.enums.CounsellingRoomCourTypeEnum;
import com.ym.medical.service.IDoctorStudioSV;
import com.ym.medical.service.IUserSV;

/**
 * 当前用户线程上下文对象
 *
 * @author: 李涛
 * @version: 2020年09月17日 17:38
 */
public class SessionContext {

	/**
	 * 获取当前用户
	 *
	 * @return
	 */
	public static UserEntity getCurrUser() {
		Long loginId = ShiroUtil.getLoginId();
		IUserSV userSV = SpringUtil.getBean(IUserSV.class);
		return userSV.selectById(loginId);
	}

	/**
	 * 获取当前工作室
	 *
	 * @return
	 */
	public static DoctorStudioEntity getCurrDoctorStudio() {
		Long loginId = ShiroUtil.getLoginId();
		IDoctorStudioSV doctorStudioSV = SpringUtil.getBean(IDoctorStudioSV.class);
		return doctorStudioSV.getDoctorStudio(loginId);
	}

	/**
	 * 获取当前医生的类型
	 */
	public static CounsellingRoomCourTypeEnum getCurrDoctorType(){
		UserDoctorViewEntity loginUser = ShiroUtil.getLoginUser(UserDoctorViewEntity.class);
		CounsellingRoomCourTypeEnum doctorType = DictEnum.valueOfEnum(CounsellingRoomCourTypeEnum.class,loginUser.getDoctCategory());
		return doctorType;
	}
}
